const express = require('express');
const router = express.Router();

const checkLogin = require('./../middlewares/check').checkLogin;

/**
 * GET /logout 退出
 */
router.get('/', checkLogin, (req, res, next) => {
    //清空session中user信息
    req.session.user = null;
    req.flash('success', '退出成功');
    //退出后重定向到首页
    res.redirect('/posts');
});
module.exports = router;
